<script setup lang="ts">
import TitleCard from "@/components/titleCard.vue";
import CarouselTable from './CarouselTable.vue';
import { onMounted, ref } from 'vue';
import { heparinCount, heparinList,archenteronCount } from '../api/index'
//肝素钠台账图表
let tableData: any = ref([])
//肝素钠总数据
let heparinSodiumTotalData: any = ref('')
//原肠加工、库衣库存
let fromData:any = ref({})
//获取肝素钠台账图表
const getHeparinCount = async () => {
    let res: any = await heparinCount({})
    heparinSodiumTotalData.value = res.data
}
// 获取肝素钠总数据
const getHeparinList = async () => {
    let res: any = await heparinList({})
    tableData.value = res.data
}

// 获取原肠加工、库衣库存
const getArchenteronCount =async () => {
    let res: any = await archenteronCount({})
    fromData.value = res.data
    console.log(fromData);
    
}
onMounted(() => {
    getHeparinCount()
    getHeparinList()
    getArchenteronCount()
})
</script>

<template>
    <div class="contentLeftItemBox">
        <div class="contentLeftItem">
            <TitleCard></TitleCard>
            <div class="contentLeftItemCard">
                <div class="item">
                    <img class="itemImg" src="../assets/img/cardIcon.png" alt="">
                    <div class="contentItem">
                        <div class="name">毛重（g）</div>
                        <div class="number">{{ heparinSodiumTotalData[0]?.value || 0 }}</div>
                    </div>
                </div>

                <div class="item">
                    <img class="itemImg" src="../assets/img/cardIcon1.png" alt="">
                    <div class="contentItem">
                        <div class="name">净重（g）</div>
                        <div class="number1">{{ heparinSodiumTotalData[1]?.value || 0 }}</div>
                    </div>
                </div>


            </div>
        </div>
        <div class="contentLeftItem contentLeftItemHeight ">
            <TitleCard title="肝素钠台账"></TitleCard>
            <CarouselTable class="CarouselTable" :headers="['生产日期', '小肠加工数量', '毛重（g）', '净重（g）']" :tableData="tableData"
                :isBoolean="true" />
        </div>
        <div class="contentLeftItem">
            <TitleCard title="原肠加工、肠衣库存"></TitleCard>
            <div class="contentLeftItemData">
                <div class="contentLeftItemDataTop">
                    <img src="../assets/img/bir.png" alt="" class="bir">
                    <div class="contentLeftItemDataTopInfo">
                        <div>
                            总数
                            <span class="gre">{{fromData.total?fromData.total:0}}</span>
                        </div>
                        <div>
                            出成
                            <span class="blue">{{fromData.yield?fromData.yield:0}}</span>
                        </div>
                        <div>
                            出成率
                            <span class="blue">{{fromData.yieldRate?fromData.yieldRate+'':'0'}}</span>
                        </div>
                    </div>
                </div>
                <div class="contentLeftItemDataBtm">
                    <div class="contentLeftItemDataBtmItem" v-for="(item,i) in fromData.dataList" :key="i">
                        <div class="progress">
                            <a-progress type="circle" :size="60" trailColor="#2B4C8B" strokeColor="#36F8FF" :percent="item.value" />
                        </div>
                        <div class="contentLeftItemDataBtmItemName">{{item.label}}</div>
                        <div class="contentLeftItemDataBtmItemNumber">{{item.num}}</div>
                    </div>
                 
                </div>
            </div>
        </div>
    </div>
</template>

<style scoped lang="scss">
.contentLeftItemBox {
    display: flex;
    flex-direction: column;
    height: 100%;

    .contentLeftItem {
        .contentLeftItemCard {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 26px 0 30px;

            .item {
                width: 50%;
                display: flex;
                align-items: center;
                justify-items: center;

                .itemImg {
                    width: 50%;

                }

                .contentItem {
                    display: flex;
                    flex-direction: column;

                    .name {
                        font-size: 11px;
                        color: #FFFFFF;
                    }

                    .number {
                        font-weight: bold;
                        font-size: 21px;
                        text-align: left;
                        padding-top: 7px;
                        color: #FFC925;

                    }

                    .number1 {
                        font-weight: bold;
                        font-size: 21px;
                        text-align: left;
                        padding-top: 7px;
                        color: #20DA33;
                    }
                }
            }

        }

        .contentLeftItemData {
            padding: 34px 0;

            .contentLeftItemDataTop {
                display: flex;
                align-items: center;
                justify-content: space-between;

                .bir {
                    width: 36px;
                    height: 36px;
                }

                .contentLeftItemDataTopInfo {
                    text-align: left;
                    margin-left: 10px;
                    flex: 1;
                    display: flex;
                    align-items: center;
                    justify-content: space-between;
                    font-size: 12px;
                    padding: 6px 0;
                    background: linear-gradient(90deg, rgba(0, 20, 61, 0) 0%, rgba(49, 149, 255, 0.6) 49%, rgba(7, 40, 91, 0.15) 100%);

                    div {
                        display: flex;
                        align-items: center;
                    }

                    .gre {
                        font-weight: bold;
                        font-size: 21px;
                        color: #FFC925;
                        padding-left: 6px;
                    }

                    .blue {
                        padding-left: 6px;
                        font-weight: bold;
                        font-size: 21px;
                        color: #20DA33;
                    }
                }
            }

            .contentLeftItemDataBtm {
                display: flex;
                justify-content: space-between;

                .progress {
                    ::v-deep .ant-progress-text {
                        color: #ffffff;
                    }

                    padding-top: 46px;
                }

                .contentLeftItemDataBtmItem {
                    width: 25%;
                    display: flex;
                    align-items: center;
                    flex-direction: column;

                    .contentLeftItemDataBtmItemName {
                        padding: 6px 0;
                        font-weight: bold;
                        font-size: 12px;
                        color: #FFFFFF;
                    }

                    .contentLeftItemDataBtmItemNumber {
                        color: #36F8FF;
                        font-weight: bold;
                        font-size: 21px;
                        line-height: 25px;
                    }
                }
            }
        }
    }

    .contentLeftItemHeight {
        flex: 1;

        .CarouselTable {
            height: calc(100% - 50px);
        }
    }
}
</style>
